﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WFONE
{
    public partial class TopWindows : Form
    {
        public static CDevice cdevice = null;     

        public TopWindows()
        {
            InitializeComponent();
            cdevice = CDeviceList.cDeviceListHead;
            while (cdevice != null)
            {
                DeviceName.Items.Add(cdevice.name);
                cdevice = cdevice.next;
            }
        }    

        private void SingleBtn_Click(object sender, MouseEventArgs e)
        {
            if (DeviceName.Text == "")
            {
                MessageBox.Show("请输入设备编号", "提示信息", MessageBoxButtons.OK);
            }
            else
            {
                cdevice = CDeviceList.SearchDevice(DeviceName.Text);
                Single01 cSingle01 = new Single01();
                cSingle01.Visible = false;
                cSingle01.ShowDialog();
                        
            }

        }
  
        private void DoubleBtn_Click(object sender, MouseEventArgs e)
        {
            if (DeviceName.Text == "")
            {
                MessageBox.Show("请输入设备编号", "提示信息", MessageBoxButtons.OK);
            }
            else
            {
                cdevice = CDeviceList.SearchDevice(DeviceName.Text);
                Double01 cDouble01 = new Double01();
                cDouble01.Visible = false;
                cDouble01.ShowDialog();

            }
        }
        public  void Update_DeviceName()
        {
            DeviceName.Items.Clear();
            cdevice = CDeviceList.cDeviceListHead;
            while (cdevice != null)
            {
                DeviceName.Items.Add(cdevice.name);
                cdevice = cdevice.next;
            }
        }     

        private void AddBtn_MouseClick(object sender, MouseEventArgs e)
        {
            AddDevice caddDevice01 = new AddDevice();           
            caddDevice01.Visible = false;
            caddDevice01.ShowDialog();
            Update_DeviceName();//这里有疑问
        }

    }
}
